/**
 * Author: mg12
 * Update: 2010/11/28
 * Website: http://www.neoease.com/
 *
 +-------------------------------------------------
 * @link
 * @copyright
 * @author Haijun Wu <nicholasinlove@126.com>
 +------------------------------------------------- 
 * 
 * $Id$
 */

(function() {

	function page(blogurl, start, loading) {
		var url = blogurl + '/act/recent_ajax/start/' + start;
		runChange(url, loading);
	}
	
	function detail(id, blogurl, start, loading) {
		var url = blogurl + '/act/detail_ajax/id/' + id + '/start/' + start;
		runChange(url, loading);
	}

	function runChange(url, loading) {
		jQuery.ajax({
			type:        'GET',
			url:          url,
			//cache:       false,
			contentType: 'text/html; charset=utf-8',
			beforeSend: function(data) {
				document.body.style.cursor = 'wait';
				jQuery('.rc_navi').html('<span id="rc_loading">' + ((loading == undefined) ? 'Loading...' : loading + '...') + '</span>');
			},
			success: function(data) {
				jQuery('#rc_item_1').parent().fadeOut(function() {
					jQuery(this).html(data).fadeIn();
				});
				document.body.style.cursor = 'auto';
			},
			error: function(data) {
				alert('Oops, failed to load data.');
			}
		});
	}
	
	function showall(url, loading) {
		jQuery.ajax({
			type:        'GET',
			url:          url,
			contentType: 'text/html; charset=utf-8',
			beforeSend: function(data) {
				document.body.style.cursor = 'wait';
				jQuery('.ml_nav').html('<span id="rc_loading">' + ((loading == undefined) ? 'Loading...' : loading + '...') + '</span>');
			},
			success: function(data) {
				jQuery('.ml_nav').parent().fadeOut(function() {
					jQuery(this).html(data).fadeIn();
				});
				document.body.style.cursor = 'auto';
			},
			error: function(data) {
				alert('Oops, failed to load data.');
			}
		});
	}

	window['RCJS'] = {};
	window['RCJS']['page'] = page;
	window['RCJS']['detail'] = detail;
	window['RCJS']['showall'] = showall;

})();
